#include "utils/tree.h"

void deleteTree(TreeNode *root)
{
    if (root == nullptr)
    {
        return;
    }
    deleteTree(root->left);
    deleteTree(root->right);
    delete root;
}

bool treeEqual(TreeNode *root1, TreeNode *root2)
{
    if (root1 == nullptr && root2 == nullptr)
    {
        return true;
    }
    if (root1 == nullptr || root2 == nullptr)
    {
        return false;
    }
    if (!treeEqual(root1->left, root2->left) ||
        !treeEqual(root1->right, root2->right))
    {
        return false;
    }
    return root1->val == root2->val;
}